<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ include file="/views/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>众秀众筹</title>
	<meta name="Keywords" content="众筹，众筹网，众筹导航，众筹门户，股权众筹，众筹平台，众筹圈子人，众筹项目，众筹三方
影视众筹，店铺众筹，餐饮众筹，众筹报告，创业众筹，投后管理，项目融资，项目众筹，权力的游戏，冰与火之歌" />
	<meta name="Description" content="汇集各行业高手分析众筹项目，行业问答，众筹资讯。" />
	<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
	<meta name="renderer" content="webkit"/>
	<link rel="stylesheet" href="<%=path%>/css/bootstrap/3.3.5/css/bootstrap.min.css" />
	<link rel="stylesheet" href="<%=path%>/css/cropper.min.css" />
	<link rel="stylesheet" href="<%=path%>/css/cz.css" />

	<script src="<%=path%>/js/jquery-1.11.0.min.js"></script>
	<script src="<%=path%>/js/plugins/datapicker/bootstrap-datepicker.js"></script>
	<script src="<%=path%>/js/plugins/layer/layer.js"></script>
	<script src="<%=path%>/css/bootstrap/3.3.5/js/bootstrap.min.js"></script>

	<script src="<%=path%>/js/slider.js"></script>
	<script src="<%=path%>/js/cropper.min.js"></script>
	<script src="<%=path%>/js/common.js"></script>
	<script type="text/javascript" src="<%=path %>/js/plugins/ajaxfileupload.js"></script>
</head>
<body class="gray-bg">
<jsp:include page="/views/commons/header.jsp"></jsp:include>
<div class="container page-single">
	<div class="col-md-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title">资讯编辑</h3>
			</div>
			<div class="panel-body event-create">
				<form class="form-horizontal" id="news_form" action="javascript:insertNews()">
					<input type="hidden" name="newsId" value="${news.newsId}"/>
					<div class="form-group">
						<label class="col-sm-1 control-label">标题<em>*</em></label>
						<div class="col-sm-10">
							<input type="text" class="form-control" placeholder="标题" name="newsTitle" value="${news.newsTitle}"></div>
					</div>
					
					<d:radio  describe="资讯/贷款" tableColumn="news_type" fieldName="newsType" 
							  value="${news.newsType}" queryFunction="newsTypeChange"></d:radio>
					
					<d:checkBox  describe="资讯标签" tableColumn="news_label" fieldName="newsLabel" value="${news.newsLabel}"></d:checkBox>
					<div id="news_classify_div">	
					<d:radio describe="资讯分类" tableColumn="news_classify" fieldName="newsClassify" value="${news.newsClassify}"></d:radio>
					</div>
					<div id="art_classify_div">
					<d:radio describe="贷款信息分类" tableColumn="art_classify" fieldName="artClassify" value="${news.artClassify}"></d:radio>
					</div>
					<div class="form-group">
						<label class="col-sm-1 control-label">来源<em>*</em></label>
						<div class="col-sm-4">
							<input type="text" class="form-control" placeholder="来源" name="newsFrom" value="${news.newsFrom}">
						</div>
						<label class="col-sm-1 control-label">作者<em>*</em></label>
						<div class="col-sm-4">
							<input type="text" class="form-control" placeholder="作者" name="newsAuthor" value="${news.newsAuthor}">
						</div>
					</div>
					<div class="form-group" id="data_news_time">
						<label class="col-sm-1 control-label">发布时间<em>*</em></label>
						<div class="col-sm-10">
							<div id="datepicker" class="input-daterange input-group">
								<input type="text"  name="publishTime"  value="<fmt:formatDate value='${news.publishTime}' pattern='yyyy-MM-dd'/>" class="input-sm form-control">
							</div>
						</div>
					</div>
					
					<div class="form-group">
						<label for="aa" class="col-sm-1 control-label">资讯图片 <em>*</em></label>
						<div class="col-sm-10">
							<div class="img-container">
								<img id="news_picture_img" src="<%=path %>/uncheck/pictures/servlet?id=${news.newsPicture}" width="240" height="160" alt="Picture">
							</div>
							<label class="btn btn-primary" for="news_picture_file" title="上传图片">
								<input type="file" class="hide" id="news_picture_file" name="file" accept="image/*" onchange="javascript:uploadImage('news_picture_img','news_picture_file','news_picture',2)">上传新图片
							</label>
							<input type="hidden" id="news_picture" name="newsPicture" value="${news.newsPicture}">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-1 control-label">关键字<em>*</em></label>
						<div class="col-sm-10">
							<input type="text" class="form-control" placeholder="关键字" name="newsKeyWords" value="${news.newsKeyWords}">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-1 control-label">摘要<em>*</em></label>
						<div class="col-sm-10">
							<textarea name="newsDigest" rows="3" cols="93">${news.newsDigest}</textarea>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-sm-1 control-label">新闻内容<em>*</em></label>
						<div class="col-sm-10">
							<textarea name="newsInfo" style="width:680px;height:400px;visibility:hidden;">
							<fns:encodes value="${news.newsInfo}" type="4"/>
							</textarea>
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-9 col-sm-offset-2">
							<button  class="btn btn-primary" id="news_confirm_btn" >提交</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<jsp:include page="/views/commons/footer.jsp"></jsp:include>

<link rel="stylesheet" href="<%=path %>/js/plugins/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="<%=path %>/js/plugins/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="<%=path %>/js/plugins/kindeditor/lang/zh_CN.js"></script>

<script type="text/javascript">
	$(function() {
	var editor;
		KindEditor.ready(function(K) {
			editor = K.create('textarea[name="newsInfo"]', {
				allowFileManager: false,
				allowUpload : true,
				uploadJson:"<%=path %>/uncheck/pictures/upload/json",
				items : ['fontname', 'fontsize', '|',
				         'bold','italic', 'underline', 'forecolor','hilitecolor','link','|',
				         'justifyleft', 'justifycenter', 'justifyright','justifyfull','clearhtml', 'quickformat','|',
				         'image', 'table','emoticons','baidumap', '|', 'about'
				 ]
			});
		});
		$("#data_news_time .input-daterange").datepicker({
			keyboardNavigation: !1,
			forceParse: !1,
			autoclose: !0
		})
	})
	function insertNews(){
		$("#news_confirm_btn").addClass("disabled").attr("disabled","disabled").val("提交中");
		$.ajax({
			url : path + "/check/news/update",
			type : "post",
			dataType : "json",
			data : $("#news_form").serialize(),
			success : function(data)
			{
				if(data.result){
					layer.msg("发布成功",{icon: 1});;
					window.location.href=path + "/views/news/news_list.jsp";
				}else{
					layer.msg(data.message,{icon: 2});;
					$("#news_confirm_btn").removeClass("disabled").removeAttr("disabled").val("提交");
				}
			},error:function(){
				layer.msg("服务器网络繁忙",{icon: 2});
				$("#news_confirm_btn").removeClass("disabled").removeAttr("disabled").val("提交");
			}
		});
	}
	
	function newsTypeChange(newsType){
		if(newsType==1){
			$("#news_classify_div").show();
			$("#art_classify_div").hide();
		}else{
			$("#news_classify_div").hide();
			$("#art_classify_div").show();
		}
	}
</script>
</body>
</html>